<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>6.匀速运动封装</title>
    <style>
        .container{
            width: 800px;
            margin: 50px;
        }
        #box{
            width: 1300px;
            height: 500px;
            border: solid 1px red;
            position: relative;
            margin-top: 10px;
        }
        #move{
            width: 100px;
            height: 100px;
            background-color: pink;
            position: absolute;
        }
    </style>
</head>
<body>
    <div class="container">
        <button id="left-btn">向左走</button>
        <button id="right-btn">向右走</button>
    </div>
    <!-- id="box"移动的范围 -->
    <div id="box">
        <!-- 移动的物体 -->
        <div id="move"></div>
        
    </div> 
</body>
<script src="./js/tools.js"></script>
<script>
    /* 
    1.要干什么
    2.会有那些情况出现
    3.需要那些必要条件
    */
    var leftBtn=document.getElementById('left-btn');
    var rightBtn=document.getElementById('right-btn');
    var box=document.getElementById('box');
    var move=document.getElementById('move');
    var max=box.offsetWidth-move.offsetWidth;
    var x=move.offsetLeft;
    
    console.log(x)
    rightBtn.onclick=function(e){
        animationMove(move,max)
    }
    leftBtn.onclick=function(e){
        animationMove(move,0)
    }


  
</script>
</html>